﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OneMake.Model
{
    //库销分析
    public class report_kx_stat
    {
        public string retport_type{get; set;}

        [MapToField(FieldName = "销售SKU数")]
        public int sale_sku_num { get; set; }

        [MapToField(FieldName = "销售数量")]
        public int sale_num { get; set; }

        [MapToField(FieldName = "销售金额")]
        public double sale_amout { get; set; }

        [MapToField(FieldName = "销售吊牌额")]
        public double sale_label_amount { get; set; }

        [MapToField(FieldName = "销售金额%")]
        public double sale_amount_rate { get; set; }

        [MapToField(FieldName = "销售吊牌额%")]
        public double sale_lable_amount_rate { get; set; }

        [MapToField(FieldName = "销售均价")]
        public double avg_sale_price { get; set; }

        [MapToField(FieldName = "吊牌均价")]
        public double avg_label_price { get; set; }

        [MapToField(FieldName = "平均折扣")]
        public double ave_off { get; set; }
    }

    partial class ReportHelper
    {
        public List<report_kx_stat> get_report_kx_stat(string brand, DateTime beginTime, DateTime endTime)
        {
            System.Diagnostics.Debug.Assert(beginTime <= endTime);

            var db = new PetaPoco.Database("mysql" + UserSession.Network);
            string sql = "select * from mf_m_gmsd where brand=@0 and (stat_datetime between @1 and @2)";
            List<report_kx_stat> reports = db.Query<report_kx_stat>(sql, brand, beginTime, endTime).ToList();
            return reports;
        }
    }
}
